require 'redmine'
require_dependency 'query'

module QueryPatchExtendedColumn

  def self.included(base) # :nodoc:
    base.send(:class_variable_set, :@@available_columns, [
        QueryColumn.new(:project, :sortable => "#{Project.table_name}.name", :groupable => true),
        QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position", :groupable => true),
        QueryColumn.new(:parent, :sortable => ["#{Issue.table_name}.root_id", "#{Issue.table_name}.lft ASC"], :default_order => 'desc', :caption => :field_parent_issue),
        QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position", :groupable => true),
        QueryColumn.new(:priority, :sortable => "#{IssuePriority.table_name}.position", :default_order => 'desc', :groupable => true),
        QueryColumn.new(:subject, :sortable => "#{Issue.table_name}.subject"),
        QueryColumn.new(:author),
        QueryColumn.new(:assigned_to, :sortable => ["#{User.table_name}.lastname", "#{User.table_name}.firstname", "#{User.table_name}.id"], :groupable => true),
        QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on", :default_order => 'desc'),
        QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name", :groupable => true),
        QueryColumn.new(:fixed_version, :sortable => ["#{Version.table_name}.effective_date", "#{Version.table_name}.name"], :default_order => 'desc', :groupable => true),
        QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date"),
        QueryColumn.new(:due_date, :sortable => "#{Issue.table_name}.due_date"),
        QueryColumn.new(:spent_hours),
        QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours"),
        QueryColumn.new(:done_ratio, :sortable => "#{Issue.table_name}.done_ratio", :groupable => true),
        QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc'),
      ])
  end

end
